package com.example.demo.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.demo.entity.WrongQuestion;
import com.example.demo.mapper.WrongQuestionMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class WrongQuestionService {
  @Autowired
  WrongQuestionMapper wrongQuestionMapper;

  public int getWrongQuestionCount(String userId){
    return wrongQuestionMapper.selectCount(new QueryWrapper<WrongQuestion>().eq("user_id",userId));
  }

  public List<WrongQuestion> getWrongQuestion(String userId){
    return wrongQuestionMapper.selectList(new QueryWrapper<WrongQuestion>().select("question_id").eq("user_id",userId));
  }

  public int addWrongQuestion(WrongQuestion wrongQuestion){
    return wrongQuestionMapper.insert(wrongQuestion);
  }
}
